package com.gitee.huanminabc.utils_tools.security.access;

import com.gitee.huanminabc.utils_tools.security.vo.SecurityResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 自定义登录成功处理器：返回状态码200
 * @author huanmin
 * @date 2024/1/24
 */
@Component
public class SecurityAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
    @Override
    public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
        // 将字符串渲染到客户端
        SecurityResponse.success("登录成功",httpServletResponse);
    }

}
